import { _decorator, UITransform ,Node} from "cc";
import { UIComponent } from "../../platform/ui/UIComponent";
import { bind } from "../../platform/ui/UIDecorator";


export class Enimy extends UIComponent{


    @bind(Node)
    blood:Node;

    private _bloodValue:number = 100;

    public get bloodValue():number{
        return this._bloodValue;
    }
      
    public set bloodValue(value:number){
        this._bloodValue = value;
        if(this.bloodValue < 0) {
            this.bloodValue = 0;
            this.die()
        }
        this.blood.getComponent(UITransform).width = value;
    }

    public boodChange(value:number){
        this.bloodValue -= value;
    }

    die(){
        this.node.active = false;
        this.node.removeFromParent()
    }
}